package com.shudai.largescreen.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import com.alibaba.fastjson.JSON;
import com.shudai.largescreen.mapper.SalesPlanMapper;
import com.shudai.largescreen.pojo.User;
import com.shudai.largescreen.pojo.dto.UserDetailDto;
import com.shudai.largescreen.pojo.vo.*;
import com.shudai.largescreen.service.SalesPlanService;
import com.shudai.largescreen.util.DateQuery;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Service
@RequiredArgsConstructor
@Slf4j
public class SalesPlanServiceImpl implements SalesPlanService {

    private final SalesPlanMapper salesPlanMapper;

    @Override
    public Map<String, Object> getSalesmanRepurchase(String province, String region, String type, String startTime) {
        System.out.println("u绝不能仅仅 "+type);

        if (StringUtils.isEmpty(startTime)) {
            startTime = ((DateTime.now() + "").split(" ")[0].split("-")[0]) + ((DateTime.now() + "").split(" ")[0].split("-")[1]);
        }
        List<User> users = salesPlanMapper.findSysUser(province, region);

        Integer totalMoth = 1500;
        Integer totalWeek = 500;


        Map<String, Object> salesmanRepu = getSalesmanRepu(startTime, users, totalMoth, totalWeek);
        if (!StringUtils.isEmpty(type) && type.equals("1")){
            List<SalesmanList> collect1 = new ArrayList<>();
            salesmanRepu.put("salesmanList", collect1);
        }
        return salesmanRepu;
    }

    public Map<String, Object> getSalesmanRepu(String startTime, List<User> users, Integer totalMoth, Integer totalWeek) {
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        //获取传入月份的开始和结束
        LocalDate mothSomeStart = DateQuery.getMothSomeStart(startTime);
        LocalDate mothSomeEnd = DateQuery.getMothSomeEnd(startTime);
        //查业务员
        LocalDateTime start = LocalDateTime.parse(mothSomeStart + " 00:00:00", df);
        LocalDateTime end = LocalDateTime.parse(mothSomeEnd + " 00:00:00", df);

        Map<String, Object> maps = new HashMap<>();
        if (!CollectionUtils.isEmpty(users)) {
            List<Long> collect = users.stream().map(User::getId).collect(Collectors.toList());

            //拜访+回访
            List<ChartDataData> visit = salesPlanMapper.findTotalUserRe(collect, start, end);
            List<ChartDataData> revisit = salesPlanMapper.findTotalVisity(collect, start, end);

            //定制目标
            List<ChartDataData> customized = salesPlanMapper.findCustomized(collect, start, end);
            //标准目标
            List<ChartDataData> standard = salesPlanMapper.findStandard(collect, start, end);

            Map<String, Object> objectMap1 = new HashMap<>();
            //月总汇
            MonthTotal monthTotal = new MonthTotal();
            monthTotal.setSampleTarget(totalMoth);
            monthTotal.setVisitTarget(totalMoth);
            monthTotal.setCustomTarget(totalMoth);
            //标准
            monthTotal.setSampleFinished(standard.stream().mapToInt(ChartDataData::getTotal).sum());
            monthTotal.setSamplePercent(new BigDecimal(standard.stream().mapToInt(ChartDataData::getTotal).sum()).divide(new BigDecimal(totalMoth), 2, RoundingMode.HALF_UP));

            //定制
            monthTotal.setCustomFinished(customized.stream().mapToInt(ChartDataData::getTotal).sum());
            monthTotal.setCustomPercent(new BigDecimal(customized.stream().mapToInt(ChartDataData::getTotal).sum()).divide(new BigDecimal(totalMoth), 2, RoundingMode.HALF_UP));

            //拜访
            monthTotal.setVisitFinished(visit.stream().mapToInt(ChartDataData::getTotal).sum() + revisit.stream().mapToInt(ChartDataData::getTotal).sum());
            monthTotal.setVisitPercent(new BigDecimal((visit.stream().mapToInt(ChartDataData::getTotal).sum() + revisit.stream().mapToInt(ChartDataData::getTotal).sum())).divide(new BigDecimal(totalMoth), 2, RoundingMode.HALF_UP));

            maps.put("monthTotal", monthTotal);

            //第一周
            //拜访  isBefore 包括自己 之前  isAfter 不包括自己 之后

            List<Map<String, Object>> charts = new ArrayList<>();
            int viSum1 = visit.stream().filter(x -> x.getTimeLocal().isBefore(start.plusDays(8))).mapToInt(ChartDataData::getTotal).sum();
            int reSum1 = revisit.stream().filter(x -> x.getTimeLocal().isBefore(start.plusDays(8))).mapToInt(ChartDataData::getTotal).sum();
            Map<String, Object> mapv1 = new HashMap<>();
            mapv1.put("target", totalWeek);
            mapv1.put("finish", viSum1 + reSum1);
            mapv1.put("percent", (new BigDecimal((viSum1 + reSum1))).divide(new BigDecimal(totalWeek), 2, RoundingMode.HALF_UP));
            objectMap1.put("visit", mapv1);
            //定制
            int customizedSum1 = customized.stream().filter(x -> x.getTimeLocal().isBefore(start.plusDays(8))).mapToInt(ChartDataData::getTotal).sum();
            Map<String, Object> mapc1 = new HashMap<>();
            mapc1.put("target", totalWeek);
            mapc1.put("finish", customizedSum1);
            mapc1.put("percent", (new BigDecimal(customizedSum1)).divide(new BigDecimal(totalWeek), 2, RoundingMode.HALF_UP));
            objectMap1.put("custom", mapc1);
            //标准目标
            int standardSum1 = standard.stream().filter(x -> x.getTimeLocal().isBefore(start.plusDays(8))).mapToInt(ChartDataData::getTotal).sum();
            Map<String, Object> maps1 = new HashMap<>();
            maps1.put("target", totalWeek);
            maps1.put("finish", standardSum1);
            maps1.put("percent", (new BigDecimal(standardSum1)).divide(new BigDecimal(totalWeek), 2, RoundingMode.HALF_UP));
            objectMap1.put("sample", maps1);

            Map<String, Object> chart1 = new HashMap<>();
            chart1.put("name", "一周");
            chart1.put("data1", viSum1 + reSum1);
            chart1.put("data2", customizedSum1);
            chart1.put("data3", standardSum1);
            charts.add(chart1);
            Map<String, Object> objectMap2 = new HashMap<>();
            //第二周
            //拜访
            int viSum2 = visit.stream().filter(x -> x.getTimeLocal().isAfter(start.plusDays(8)) && x.getTimeLocal().isBefore(start.plusDays(16))).mapToInt(ChartDataData::getTotal).sum();
            int reSum2 = revisit.stream().filter(x -> x.getTimeLocal().isAfter(start.plusDays(8)) && x.getTimeLocal().isBefore(start.plusDays(16))).mapToInt(ChartDataData::getTotal).sum();
            Map<String, Object> mapv2 = new HashMap<>();
            mapv2.put("target", totalWeek);
            mapv2.put("finish", viSum2 + reSum2);
            mapv2.put("percent", (new BigDecimal((viSum2 + reSum2))).divide(new BigDecimal(totalWeek), 2, RoundingMode.HALF_UP));
            objectMap2.put("visit", mapv2);
            //定制
            int customizedSum2 = customized.stream().filter(x -> x.getTimeLocal().isAfter(start.plusDays(8)) && x.getTimeLocal().isBefore(start.plusDays(16))).mapToInt(ChartDataData::getTotal).sum();
            Map<String, Object> mapc2 = new HashMap<>();
            mapc2.put("target", totalWeek);
            mapc2.put("finish", customizedSum2);
            mapc2.put("percent", (new BigDecimal(customizedSum2)).divide(new BigDecimal(totalWeek), 2, RoundingMode.HALF_UP));
            objectMap2.put("custom", mapc2);
            //标准目标
            int standardSum2 = standard.stream().filter(x -> x.getTimeLocal().isAfter(start.plusDays(8)) && x.getTimeLocal().isBefore(start.plusDays(16))).mapToInt(ChartDataData::getTotal).sum();
            Map<String, Object> maps2 = new HashMap<>();
            maps2.put("target", totalWeek);
            maps2.put("finish", standardSum2);
            maps2.put("percent", (new BigDecimal(standardSum2)).divide(new BigDecimal(totalWeek), 2, RoundingMode.HALF_UP));
            objectMap2.put("sample", maps2);

            Map<String, Object> chart2 = new HashMap<>();
            chart2.put("name", "二周");
            chart2.put("data1", viSum2 + reSum2);
            chart2.put("data2", customizedSum2);
            chart2.put("data3", standardSum2);
            charts.add(chart2);
            Map<String, Object> objectMap3 = new HashMap<>();
            //第三周
            //拜访
            int viSum3 = visit.stream().filter(x -> x.getTimeLocal().isAfter(start.plusDays(16)) && x.getTimeLocal().isBefore(start.plusDays(24))).mapToInt(ChartDataData::getTotal).sum();
            int reSum3 = revisit.stream().filter(x -> x.getTimeLocal().isAfter(start.plusDays(16)) && x.getTimeLocal().isBefore(start.plusDays(24))).mapToInt(ChartDataData::getTotal).sum();
            Map<String, Object> mapv3 = new HashMap<>();
            mapv3.put("target", totalWeek);
            mapv3.put("finish", viSum3 + reSum3);
            mapv3.put("percent", (new BigDecimal((viSum3 + reSum3))).divide(new BigDecimal(totalWeek), 2, RoundingMode.HALF_UP));
            objectMap3.put("visit", mapv3);
            //定制
            int customizedSum3 = customized.stream().filter(x -> x.getTimeLocal().isAfter(start.plusDays(16)) && x.getTimeLocal().isBefore(start.plusDays(24))).mapToInt(ChartDataData::getTotal).sum();
            Map<String, Object> mapc3 = new HashMap<>();
            mapc3.put("target", totalWeek);
            mapc3.put("finish", customizedSum3);
            mapc3.put("percent", (new BigDecimal(customizedSum3)).divide(new BigDecimal(totalWeek), 2, RoundingMode.HALF_UP));
            objectMap3.put("custom", mapc3);
            //标准目标
            int standardSum3 = standard.stream().filter(x -> x.getTimeLocal().isAfter(start.plusDays(16)) && x.getTimeLocal().isBefore(start.plusDays(24))).mapToInt(ChartDataData::getTotal).sum();
            Map<String, Object> maps3 = new HashMap<>();
            maps3.put("target", totalWeek);
            maps3.put("finish", standardSum3);
            maps3.put("percent", (new BigDecimal(standardSum3)).divide(new BigDecimal(totalWeek), 2, RoundingMode.HALF_UP));
            objectMap3.put("sample", maps3);


            Map<String, Object> chart3 = new HashMap<>();
            chart3.put("name", "三周");
            chart3.put("data1", viSum3 + reSum3);
            chart3.put("data2", customizedSum3);
            chart3.put("data3", standardSum3);
            charts.add(chart3);

            Map<String, Object> objectMap4 = new HashMap<>();
            //第四周
            //拜访
            int viSum4 = visit.stream().filter(x -> x.getTimeLocal().isAfter(start.plusDays(24))).mapToInt(ChartDataData::getTotal).sum();
            int reSum4 = revisit.stream().filter(x -> x.getTimeLocal().isAfter(start.plusDays(24))).mapToInt(ChartDataData::getTotal).sum();
            Map<String, Object> mapv4 = new HashMap<>();
            mapv4.put("target", totalWeek);
            mapv4.put("finish", viSum4 + reSum4);
            mapv4.put("percent", (new BigDecimal((viSum4 + reSum4))).divide(new BigDecimal(totalWeek), 2, RoundingMode.HALF_UP));
            objectMap4.put("visit", mapv4);
            //定制
            int customizedSum4 = customized.stream().filter(x -> x.getTimeLocal().isAfter(start.plusDays(24))).mapToInt(ChartDataData::getTotal).sum();
            Map<String, Object> mapc4 = new HashMap<>();
            mapc4.put("target", totalWeek);
            mapc4.put("finish", customizedSum4);
            mapc4.put("percent", (new BigDecimal(customizedSum4)).divide(new BigDecimal(totalWeek), 2, RoundingMode.HALF_UP));
            objectMap4.put("custom", mapc4);
            //标准目标
            int standardSum4 = standard.stream().filter(x -> x.getTimeLocal().isAfter(start.plusDays(24))).mapToInt(ChartDataData::getTotal).sum();
            Map<String, Object> maps4 = new HashMap<>();
            maps4.put("target", totalWeek);
            maps4.put("finish", standardSum4);
            maps4.put("percent", (new BigDecimal(standardSum4)).divide(new BigDecimal(totalWeek), 2, RoundingMode.HALF_UP));
            objectMap4.put("sample", maps4);

            Map<String, Object> chart4 = new HashMap<>();
            chart4.put("name", "四周");
            chart4.put("data1", viSum3 + reSum4);
            chart4.put("data2", customizedSum4);
            chart4.put("data3", standardSum4);
            charts.add(chart4);


            List<Map<String, Object>> mapList = new ArrayList<>();
            mapList.add(objectMap1);
            mapList.add(objectMap2);
            mapList.add(objectMap3);
            mapList.add(objectMap4);

            maps.put("saleData", mapList);

            List<SalesmanList> salesmanList = new ArrayList<>();

            //录入客户数量
            for (User user : users) {
                SalesmanList salesman = new SalesmanList();
                salesman.setName(user.getNickname());
                salesman.setType(0);
                salesman.setAvatar(user.getAvatar());
                salesman.setId(user.getId());

                int totalRe = 0;
                //拜访 新用户
                for (ChartDataData chartDataData : visit) {
                    if (user.getId().equals(chartDataData.getId())) {
                        totalRe++;
                    }
                }
                salesman.setRecordFinished(totalRe);
                salesman.setRecordUnf(totalMoth - totalRe);

                int customizedTotal = 0;
                //已完成定制件数
                for (ChartDataData chartDataData : customized) {
                    if (user.getId().equals(chartDataData.getId())) {
                        customizedTotal++;
                    }
                }
                salesman.setCustomFinished(customizedTotal);
                salesman.setCustomUnf(totalMoth - customizedTotal);

                int standardTotal = 0;
                //标准目标
                for (ChartDataData chartDataData : standard) {
                    if (user.getId().equals(chartDataData.getId())) {
                        standardTotal++;
                    }
                }
                salesman.setSampleFinished(standardTotal);
                salesman.setSampleUnf(totalMoth - standardTotal);

                salesmanList.add(salesman);
            }
            List<SalesmanList> collect1 = salesmanList.stream().sorted(Comparator.comparingInt(SalesmanList::getRecordFinished).reversed()).collect(Collectors.toList());

            maps.put("salesmanList", collect1);
            maps.put("chartData", charts);
        }

        return maps;

    }


    @Override
    public Map<String, Object> getSalesmanStatic(String id, String startTime) {
        if (StringUtils.isEmpty(startTime)) {
            startTime = ((DateTime.now() + "").split(" ")[0].split("-")[0]) + ((DateTime.now() + "").split(" ")[0].split("-")[1]);
        }
        Integer totalMoth = 800;
        Integer totalWeek = 200;

        List<User> users = salesPlanMapper.selectBatchIds(Collections.singleton(id));
        Map<String, Object> salesmanRepu = getSalesmanRepu(startTime, users, totalMoth, totalWeek);
        Map<String, Object> salesmanMap = new HashMap<>();
        salesmanMap.put("saleData", salesmanRepu.get("saleData"));
        salesmanMap.put("monthTotal", salesmanRepu.get("monthTotal"));
        List<SalesmanList> collect1 = (List<SalesmanList>) salesmanRepu.get("salesmanList");
        List<Map<String, Object>> charts = (List<Map<String, Object>>) salesmanRepu.get("chartData");


        String name = collect1.get(0).getName();
        String avatar = collect1.get(0).getAvatar();
        int type = collect1.get(0).getType();

        //标准
        int sampleFinished = collect1.get(0).getSampleFinished();
        int sampleUnf = collect1.get(0).getSampleUnf();

        //定制
        int customFinished = collect1.get(0).getCustomFinished();
        int customUnf = collect1.get(0).getCustomUnf();

        //拜访
        int recordFinished = collect1.get(0).getRecordFinished();
        int recordUnf = collect1.get(0).getRecordUnf();
        SalesmanList salesmanList = new SalesmanList();
        salesmanList.setId(collect1.get(0).getId());
        salesmanList.setAvatar(avatar);
        salesmanList.setName(name);
        salesmanList.setType(type);
        salesmanList.setSampleUnf(sampleUnf);
        salesmanList.setSampleFinished(sampleFinished);
        salesmanList.setVisitFinished(recordFinished);
        salesmanList.setVisitUnf(recordUnf);
        salesmanList.setCustomFinished(customFinished);
        salesmanList.setCustomUnf(customUnf);
        salesmanMap.put("userDetail", salesmanList);


        List<Map<String, Object>> mapList = new ArrayList<>();
        for (int i = 0; i < charts.size(); i++) {

            Map<String, Object> userTotal = new HashMap<>();
            userTotal.put("visitTarget", totalWeek);
            userTotal.put("visitFinished", charts.get(i).get("data1"));
            userTotal.put("visitUnf", totalWeek - (Integer) charts.get(i).get("data1"));
            userTotal.put("customTarget", totalWeek);
            userTotal.put("customFinished", charts.get(i).get("data2"));
            userTotal.put("customUnf", totalWeek - (Integer) charts.get(i).get("data2"));
            userTotal.put("sampleTarget", totalWeek);
            userTotal.put("sampleFinished", charts.get(i).get("data3"));
            userTotal.put("sampleUnf", totalWeek - (Integer) charts.get(i).get("data3"));
            mapList.add(userTotal);

        }
        salesmanMap.put("userTotal", mapList);
//        Map<String,Object> userTotal = new HashMap<>();
//        userTotal.put("visitTarget",totalWeek);
//        userTotal.put("visitFinished",recordFinished);
//        userTotal.put("visitUnf",recordUnf);
//        userTotal.put("customTarget",totalWeek);
//        userTotal.put("customFinished",customFinished);
//        userTotal.put("customUnf",customUnf);
//        userTotal.put("sampleTarget",totalWeek);
//        userTotal.put("sampleFinished",sampleFinished);
//        userTotal.put("sampleUnf",sampleUnf);
//        salesmanMap.put("userTotal",charts);

        return salesmanMap;
    }

    @Override
    public List<ExcelListVo> getAll(String province,
                                    String region,
                                    String deptName,
                                    String startTime) {

        if (StringUtils.isEmpty(startTime)) {
            startTime = ((DateTime.now() + "").split(" ")[0].split("-")[0]) + ((DateTime.now() + "").split(" ")[0].split("-")[1]);
        }
//        startTime = "202207";
        //查询部门下业务员
        List<User> sysUserDept = salesPlanMapper.findSysUserDept(province, region, deptName);
        //分组
        //自营  http://localhost:8800/api/salesman-board/salesman-excels

        for (User user : sysUserDept) {
            System.out.println("来了： " + user.getDeptName());
        }
        List<User> collect = sysUserDept.stream().filter(x -> !x.getDeptName().contains("（")).collect(Collectors.toList());
        System.out.println(JSON.toJSON(collect));
        List<Long> collectIds = collect.stream().map(User::getId).collect(Collectors.toList());
        Integer totalMoth = 800;
        Integer totalWeek = 200;


        List<ExcelListVo> excelListVos = new ArrayList<>();
        List<ExcelListVo> excelListVos1 = new ArrayList<>();

        for (int i = 0; i < collectIds.size()-1; i++) {


//            System.out.println("getId++: " + collectIds.get(i));

            Map<String, Object> salesmanStatic = getSalesList(startTime, collectIds.get(i)+"", totalMoth, totalWeek);
            ExcelListVo excelListVo = new ExcelListVo();
            excelListVo.setServiceProvider("自营");
            SalesmanList salesmanList = (SalesmanList) salesmanStatic.get("userDetail");
            excelListVo.setSalesman(salesmanList.getName());
            excelListVo.setVisit1(totalMoth);
            excelListVo.setCustom1(totalMoth);
            excelListVo.setSample1(totalMoth);
            List<Map<String, Object>> userTotal = (List<Map<String, Object>>) salesmanStatic.get("userTotal");
            for (int i1 = 0; i1 < userTotal.size(); i1++) {

                if (i1==0){
                    excelListVo.setVisit2((Integer) userTotal.get(i1).get("visitTarget"));
                    excelListVo.setCustom2((Integer) (userTotal.get(i1).get("customTarget")));
                    excelListVo.setSample2((Integer) userTotal.get(i1).get("sampleTarget"));

                    excelListVo.setVisit3((Integer) userTotal.get(i1).get("visitFinished"));
                    excelListVo.setCustom3((Integer) userTotal.get(i1).get("customFinished"));
                    excelListVo.setSample3((Integer) userTotal.get(i1).get("sampleFinished"));


                    excelListVo.setVisit4((Integer) userTotal.get(i1).get("visitUnf"));
                    excelListVo.setCustom4((Integer) userTotal.get(i1).get("customUnf"));
                    excelListVo.setSample4((Integer) userTotal.get(i1).get("sampleUnf"));
                }

                if (i1==1){
                    //
                    excelListVo.setVisit5((Integer) userTotal.get(i1).get("visitTarget"));
                    excelListVo.setCustom5((Integer) (userTotal.get(i1).get("customTarget")));
                    excelListVo.setSample5((Integer) userTotal.get(i1).get("sampleTarget"));

                    excelListVo.setVisit6((Integer) userTotal.get(i1).get("visitFinished"));
                    excelListVo.setCustom6((Integer) userTotal.get(i1).get("customFinished"));
                    excelListVo.setSample6((Integer) userTotal.get(i1).get("sampleFinished"));


                    excelListVo.setVisit7((Integer) userTotal.get(i1).get("visitUnf"));
                    excelListVo.setCustom7((Integer) userTotal.get(i1).get("customUnf"));
                    excelListVo.setSample7((Integer) userTotal.get(i1).get("sampleUnf"));
                }

                if (i1 == 2){
                    //
                    excelListVo.setVisit8((Integer) userTotal.get(i1).get("visitTarget"));
                    excelListVo.setCustom8((Integer) (userTotal.get(i1).get("customTarget")));
                    excelListVo.setSample8((Integer) userTotal.get(i1).get("sampleTarget"));

                    excelListVo.setVisit9((Integer) userTotal.get(i1).get("visitFinished"));
                    excelListVo.setCustom9((Integer) userTotal.get(i1).get("customFinished"));
                    excelListVo.setSample9((Integer) userTotal.get(i1).get("sampleFinished"));


                    excelListVo.setVisit10((Integer) userTotal.get(i1).get("visitUnf"));
                    excelListVo.setCustom10((Integer) userTotal.get(i1).get("customUnf"));
                    excelListVo.setSample10((Integer) userTotal.get(i1).get("sampleUnf"));
                }

                if (i1==3){
                    //
                    excelListVo.setVisit11((Integer) userTotal.get(i1).get("visitTarget"));
                    excelListVo.setCustom11((Integer) (userTotal.get(i1).get("customTarget")));
                    excelListVo.setSample11((Integer) userTotal.get(i1).get("sampleTarget"));

                    excelListVo.setVisit12((Integer) userTotal.get(i1).get("visitFinished"));
                    excelListVo.setCustom12((Integer) userTotal.get(i1).get("customFinished"));
                    excelListVo.setSample12((Integer) userTotal.get(i1).get("sampleFinished"));


                    excelListVo.setVisit13((Integer) userTotal.get(i1).get("visitUnf"));
                    excelListVo.setCustom13((Integer) userTotal.get(i1).get("customUnf"));
                    excelListVo.setSample13((Integer) userTotal.get(i1).get("sampleUnf"));
                }


            }

            excelListVo.setVisit14((Integer) salesmanList.getVisitFinished());
            excelListVo.setCustom14((Integer) salesmanList.getCustomFinished());
            excelListVo.setSample14((Integer) salesmanList.getSampleFinished());

            excelListVo.setVisit15((Integer) salesmanList.getVisitUnf());
            excelListVo.setCustom15((Integer) salesmanList.getCustomUnf());
            excelListVo.setSample15((Integer) salesmanList.getSampleUnf());


            excelListVos.add(excelListVo);
            excelListVos1.addAll(excelListVos);

        }

        if (!CollectionUtils.isEmpty(excelListVos)) {
            ExcelListVo listVo = new ExcelListVo();
            listVo.setServiceProvider(excelListVos.get(0).getServiceProvider() + "合计");

            //遍历列表，求各数据汇总
            listVo.setSalesman(excelListVos.stream().filter(Po -> Po.getSalesman() != null).collect(Collectors.toList()).stream().count() + "");

            listVo.setVisit1(excelListVos.stream().filter(Po -> Po.getVisit1() != null).mapToInt(ExcelListVo::getVisit1).sum());
            listVo.setCustom1(excelListVos.stream().filter(Po -> Po.getCustom1() != null).mapToInt(ExcelListVo::getCustom1).sum());
            listVo.setSample1(excelListVos.stream().filter(Po -> Po.getSample1() != null).mapToInt(ExcelListVo::getSample1).sum());

            listVo.setVisit2(excelListVos.stream().filter(Po -> Po.getVisit2() != null).mapToInt(ExcelListVo::getVisit2).sum());
            listVo.setCustom2(excelListVos.stream().filter(Po -> Po.getCustom2() != null).mapToInt(ExcelListVo::getCustom2).sum());
            listVo.setSample2(excelListVos.stream().filter(Po -> Po.getSample2() != null).mapToInt(ExcelListVo::getSample2).sum());

            listVo.setVisit3(excelListVos.stream().filter(Po -> Po.getVisit3() != null).mapToInt(ExcelListVo::getVisit3).sum());
            listVo.setCustom3(excelListVos.stream().filter(Po -> Po.getCustom3() != null).mapToInt(ExcelListVo::getCustom3).sum());
            listVo.setSample3(excelListVos.stream().filter(Po -> Po.getSample3() != null).mapToInt(ExcelListVo::getSample3).sum());

            listVo.setVisit4(excelListVos.stream().filter(Po -> Po.getVisit4() != null).mapToInt(ExcelListVo::getVisit4).sum());
            listVo.setCustom4(excelListVos.stream().filter(Po -> Po.getCustom4() != null).mapToInt(ExcelListVo::getCustom4).sum());
            listVo.setSample4(excelListVos.stream().filter(Po -> Po.getSample4() != null).mapToInt(ExcelListVo::getSample4).sum());

            listVo.setVisit5(excelListVos.stream().filter(Po -> Po.getVisit5() != null).mapToInt(ExcelListVo::getVisit5).sum());
            listVo.setCustom5(excelListVos.stream().filter(Po -> Po.getCustom5() != null).mapToInt(ExcelListVo::getCustom5).sum());
            listVo.setSample5(excelListVos.stream().filter(Po -> Po.getSample5() != null).mapToInt(ExcelListVo::getSample5).sum());

            listVo.setVisit6(excelListVos.stream().filter(Po -> Po.getVisit6() != null).mapToInt(ExcelListVo::getVisit6).sum());
            listVo.setCustom6(excelListVos.stream().filter(Po -> Po.getCustom6() != null).mapToInt(ExcelListVo::getCustom6).sum());
            listVo.setSample6(excelListVos.stream().filter(Po -> Po.getSample6() != null).mapToInt(ExcelListVo::getSample6).sum());

            listVo.setVisit7(excelListVos.stream().filter(Po -> Po.getVisit7() != null).mapToInt(ExcelListVo::getVisit7).sum());
            listVo.setCustom7(excelListVos.stream().filter(Po -> Po.getCustom7() != null).mapToInt(ExcelListVo::getCustom7).sum());
            listVo.setSample7(excelListVos.stream().filter(Po -> Po.getSample7() != null).mapToInt(ExcelListVo::getSample7).sum());

            listVo.setVisit8(excelListVos.stream().filter(Po -> Po.getVisit8() != null).mapToInt(ExcelListVo::getVisit8).sum());
            listVo.setCustom8(excelListVos.stream().filter(Po -> Po.getCustom8() != null).mapToInt(ExcelListVo::getCustom8).sum());
            listVo.setSample8(excelListVos.stream().filter(Po -> Po.getSample8() != null).mapToInt(ExcelListVo::getSample8).sum());

            listVo.setVisit9(excelListVos.stream().filter(Po -> Po.getVisit9() != null).mapToInt(ExcelListVo::getVisit9).sum());
            listVo.setCustom9(excelListVos.stream().filter(Po -> Po.getCustom9() != null).mapToInt(ExcelListVo::getCustom9).sum());
            listVo.setSample9(excelListVos.stream().filter(Po -> Po.getSample9() != null).mapToInt(ExcelListVo::getSample9).sum());

            listVo.setVisit10(excelListVos.stream().filter(Po -> Po.getVisit10() != null).mapToInt(ExcelListVo::getVisit10).sum());
            listVo.setCustom10(excelListVos.stream().filter(Po -> Po.getCustom10() != null).mapToInt(ExcelListVo::getCustom10).sum());
            listVo.setSample10(excelListVos.stream().filter(Po -> Po.getSample10() != null).mapToInt(ExcelListVo::getSample10).sum());

            listVo.setVisit11(excelListVos.stream().filter(Po -> Po.getVisit11() != null).mapToInt(ExcelListVo::getVisit11).sum());
            listVo.setCustom11(excelListVos.stream().filter(Po -> Po.getCustom11() != null).mapToInt(ExcelListVo::getCustom11).sum());
            listVo.setSample11(excelListVos.stream().filter(Po -> Po.getSample11() != null).mapToInt(ExcelListVo::getSample11).sum());

            listVo.setVisit12(excelListVos.stream().filter(Po -> Po.getVisit12() != null).mapToInt(ExcelListVo::getVisit12).sum());
            listVo.setCustom12(excelListVos.stream().filter(Po -> Po.getCustom12() != null).mapToInt(ExcelListVo::getCustom12).sum());
            listVo.setSample12(excelListVos.stream().filter(Po -> Po.getSample12() != null).mapToInt(ExcelListVo::getSample12).sum());

            listVo.setVisit13(excelListVos.stream().filter(Po -> Po.getVisit13() != null).mapToInt(ExcelListVo::getVisit13).sum());
            listVo.setCustom13(excelListVos.stream().filter(Po -> Po.getCustom13() != null).mapToInt(ExcelListVo::getCustom13).sum());
            listVo.setSample13(excelListVos.stream().filter(Po -> Po.getSample13() != null).mapToInt(ExcelListVo::getSample13).sum());

            listVo.setVisit14(excelListVos.stream().filter(Po -> Po.getVisit14() != null).mapToInt(ExcelListVo::getVisit14).sum());
            listVo.setCustom14(excelListVos.stream().filter(Po -> Po.getCustom14() != null).mapToInt(ExcelListVo::getCustom14).sum());
            listVo.setSample14(excelListVos.stream().filter(Po -> Po.getSample14() != null).mapToInt(ExcelListVo::getSample14).sum());

            listVo.setVisit15(excelListVos.stream().filter(Po -> Po.getVisit15() != null).mapToInt(ExcelListVo::getVisit15).sum());
            listVo.setCustom15(excelListVos.stream().filter(Po -> Po.getCustom15() != null).mapToInt(ExcelListVo::getCustom15).sum());
            listVo.setSample15(excelListVos.stream().filter(Po -> Po.getSample15() != null).mapToInt(ExcelListVo::getSample15).sum());

            excelListVos.add(listVo);
            excelListVos1.addAll(excelListVos);
        }


//               服务商

//
        List<User> collectD = sysUserDept.stream().filter(x -> x.getDeptName().contains("（")).collect(Collectors.toList());


        Map<Long, List<User>> collect1 = collectD.stream().collect(Collectors.groupingBy(User::getDeptId));
        for (Map.Entry<Long, List<User>> longListEntry : collect1.entrySet()) {

            excelListVos.clear();

            List<Long> collect2 = longListEntry.getValue().stream().map(User::getId).collect(Collectors.toList());

            for (int i = 0; i < collect2.size()-1; i++) {
                System.out.println("getId++: " + collect2.get(i));

                Map<String, Object> salesmanStatic = getSalesList(startTime, collect2.get(i)+"", totalMoth, totalWeek);
                ExcelListVo excelListVo = new ExcelListVo();
                excelListVo.setServiceProvider( longListEntry.getValue().get(i).getDeptName());
                SalesmanList salesmanList = (SalesmanList) salesmanStatic.get("userDetail");
                excelListVo.setSalesman(salesmanList.getName());
                excelListVo.setVisit1(totalMoth);
                excelListVo.setCustom1(totalMoth);
                excelListVo.setSample1(totalMoth);
                List<Map<String, Object>> userTotal = (List<Map<String, Object>>) salesmanStatic.get("userTotal");

//                for (int i1 = 0; i1 < userTotal.size(); i1++) {
//
//                    excelListVo.setVisit2((Integer) userTotal.get(i1).get("visitTarget"));
//                    excelListVo.setCustom2((Integer) (userTotal.get(i1).get("customTarget")));
//                    excelListVo.setSample2((Integer) userTotal.get(i1).get("sampleTarget"));
//
//                    excelListVo.setVisit3((Integer) userTotal.get(i1).get("visitFinished"));
//                    excelListVo.setCustom3((Integer) userTotal.get(i1).get("customFinished"));
//                    excelListVo.setSample3((Integer) userTotal.get(i1).get("sampleFinished"));
//
//
//                    excelListVo.setVisit4((Integer) userTotal.get(i1).get("visitUnf"));
//                    excelListVo.setCustom4((Integer) userTotal.get(i1).get("customFinished"));
//                    excelListVo.setSample4((Integer) userTotal.get(i1).get("sampleUnf"));
//
//
//                    //
//                    excelListVo.setVisit5((Integer) userTotal.get(i1).get("visitTarget"));
//                    excelListVo.setCustom5((Integer) (userTotal.get(i1).get("customTarget")));
//                    excelListVo.setSample5((Integer) userTotal.get(i1).get("sampleTarget"));
//
//                    excelListVo.setVisit6((Integer) userTotal.get(i1).get("visitFinished"));
//                    excelListVo.setCustom6((Integer) userTotal.get(i1).get("customFinished"));
//                    excelListVo.setSample6((Integer) userTotal.get(i1).get("sampleFinished"));
//
//
//                    excelListVo.setVisit7((Integer) userTotal.get(i1).get("visitUnf"));
//                    excelListVo.setCustom7((Integer) userTotal.get(i1).get("customFinished"));
//                    excelListVo.setSample7((Integer) userTotal.get(i1).get("sampleUnf"));
//
//                    excelListVo.setVisit8((Integer) userTotal.get(i1).get("visitTarget"));
//                    excelListVo.setCustom8((Integer) (userTotal.get(i1).get("customTarget")));
//                    excelListVo.setSample8((Integer) userTotal.get(i1).get("sampleTarget"));
//
//                    excelListVo.setVisit9((Integer) userTotal.get(i1).get("visitFinished"));
//                    excelListVo.setCustom9((Integer) userTotal.get(i1).get("customFinished"));
//                    excelListVo.setSample9((Integer) userTotal.get(i1).get("sampleFinished"));
//
//
//                    excelListVo.setVisit10((Integer) userTotal.get(i1).get("visitUnf"));
//                    excelListVo.setCustom10((Integer) userTotal.get(i1).get("customFinished"));
//                    excelListVo.setSample10((Integer) userTotal.get(i1).get("sampleUnf"));
//
//                    excelListVo.setVisit11((Integer) userTotal.get(i1).get("visitTarget"));
//                    excelListVo.setCustom11((Integer) (userTotal.get(i1).get("customTarget")));
//                    excelListVo.setSample11((Integer) userTotal.get(i1).get("sampleTarget"));
//
//                    excelListVo.setVisit12((Integer) userTotal.get(i1).get("visitFinished"));
//                    excelListVo.setCustom12((Integer) userTotal.get(i1).get("customFinished"));
//                    excelListVo.setSample12((Integer) userTotal.get(i1).get("sampleFinished"));
//
//
//                    excelListVo.setVisit13((Integer) userTotal.get(i1).get("visitUnf"));
//                    excelListVo.setCustom13((Integer) userTotal.get(i1).get("customFinished"));
//                    excelListVo.setSample13((Integer) userTotal.get(i1).get("sampleUnf"));
//
//
//                }
                for (int i1 = 0; i1 < userTotal.size(); i1++) {

                    if (i1==0){
                        excelListVo.setVisit2((Integer) userTotal.get(i1).get("visitTarget"));
                        excelListVo.setCustom2((Integer) (userTotal.get(i1).get("customTarget")));
                        excelListVo.setSample2((Integer) userTotal.get(i1).get("sampleTarget"));

                        excelListVo.setVisit3((Integer) userTotal.get(i1).get("visitFinished"));
                        excelListVo.setCustom3((Integer) userTotal.get(i1).get("customFinished"));
                        excelListVo.setSample3((Integer) userTotal.get(i1).get("sampleFinished"));


                        excelListVo.setVisit4((Integer) userTotal.get(i1).get("visitUnf"));
                        excelListVo.setCustom4((Integer) userTotal.get(i1).get("customUnf"));
                        excelListVo.setSample4((Integer) userTotal.get(i1).get("sampleUnf"));
                    }

                    if (i1==1){
                        //
                        excelListVo.setVisit5((Integer) userTotal.get(i1).get("visitTarget"));
                        excelListVo.setCustom5((Integer) (userTotal.get(i1).get("customTarget")));
                        excelListVo.setSample5((Integer) userTotal.get(i1).get("sampleTarget"));

                        excelListVo.setVisit6((Integer) userTotal.get(i1).get("visitFinished"));
                        excelListVo.setCustom6((Integer) userTotal.get(i1).get("customFinished"));
                        excelListVo.setSample6((Integer) userTotal.get(i1).get("sampleFinished"));


                        excelListVo.setVisit7((Integer) userTotal.get(i1).get("visitUnf"));
                        excelListVo.setCustom7((Integer) userTotal.get(i1).get("customUnf"));
                        excelListVo.setSample7((Integer) userTotal.get(i1).get("sampleUnf"));
                    }

                    if (i1 == 2){
                        //
                        excelListVo.setVisit8((Integer) userTotal.get(i1).get("visitTarget"));
                        excelListVo.setCustom8((Integer) (userTotal.get(i1).get("customTarget")));
                        excelListVo.setSample8((Integer) userTotal.get(i1).get("sampleTarget"));

                        excelListVo.setVisit9((Integer) userTotal.get(i1).get("visitFinished"));
                        excelListVo.setCustom9((Integer) userTotal.get(i1).get("customFinished"));
                        excelListVo.setSample9((Integer) userTotal.get(i1).get("sampleFinished"));


                        excelListVo.setVisit10((Integer) userTotal.get(i1).get("visitUnf"));
                        excelListVo.setCustom10((Integer) userTotal.get(i1).get("customUnf"));
                        excelListVo.setSample10((Integer) userTotal.get(i1).get("sampleUnf"));
                    }

                    if (i1==3){
                        //
                        excelListVo.setVisit11((Integer) userTotal.get(i1).get("visitTarget"));
                        excelListVo.setCustom11((Integer) (userTotal.get(i1).get("customTarget")));
                        excelListVo.setSample11((Integer) userTotal.get(i1).get("sampleTarget"));

                        excelListVo.setVisit12((Integer) userTotal.get(i1).get("visitFinished"));
                        excelListVo.setCustom12((Integer) userTotal.get(i1).get("customFinished"));
                        excelListVo.setSample12((Integer) userTotal.get(i1).get("sampleFinished"));


                        excelListVo.setVisit13((Integer) userTotal.get(i1).get("visitUnf"));
                        excelListVo.setCustom13((Integer) userTotal.get(i1).get("customUnf"));
                        excelListVo.setSample13((Integer) userTotal.get(i1).get("sampleUnf"));
                    }


                }

                excelListVo.setVisit14((Integer) salesmanList.getVisitFinished());
                excelListVo.setCustom14((Integer) salesmanList.getCustomFinished());
                excelListVo.setSample14((Integer) salesmanList.getSampleFinished());

                excelListVo.setVisit15((Integer) salesmanList.getVisitUnf());
                excelListVo.setCustom15((Integer) salesmanList.getCustomUnf());
                excelListVo.setSample15((Integer) salesmanList.getSampleUnf());


                excelListVos.add(excelListVo);

                excelListVos1.addAll(excelListVos);

            }

            if (!CollectionUtils.isEmpty(excelListVos)) {

                ExcelListVo listVo = new ExcelListVo();
                listVo.setServiceProvider(longListEntry.getValue().get(0).getDeptName() + "合计");

                //遍历列表，求各数据汇总
                listVo.setSalesman(excelListVos.stream().filter(Po -> Po.getSalesman() != null).collect(Collectors.toList()).stream().count() + "");

                listVo.setVisit1(excelListVos.stream().filter(Po -> Po.getVisit1() != null).mapToInt(ExcelListVo::getVisit1).sum());
                listVo.setCustom1(excelListVos.stream().filter(Po -> Po.getCustom1() != null).mapToInt(ExcelListVo::getCustom1).sum());
                listVo.setSample1(excelListVos.stream().filter(Po -> Po.getSample1() != null).mapToInt(ExcelListVo::getSample1).sum());

                listVo.setVisit2(excelListVos.stream().filter(Po -> Po.getVisit2() != null).mapToInt(ExcelListVo::getVisit2).sum());
                listVo.setCustom2(excelListVos.stream().filter(Po -> Po.getCustom2() != null).mapToInt(ExcelListVo::getCustom2).sum());
                listVo.setSample2(excelListVos.stream().filter(Po -> Po.getSample2() != null).mapToInt(ExcelListVo::getSample2).sum());

                listVo.setVisit3(excelListVos.stream().filter(Po -> Po.getVisit3() != null).mapToInt(ExcelListVo::getVisit3).sum());
                listVo.setCustom3(excelListVos.stream().filter(Po -> Po.getCustom3() != null).mapToInt(ExcelListVo::getCustom3).sum());
                listVo.setSample3(excelListVos.stream().filter(Po -> Po.getSample3() != null).mapToInt(ExcelListVo::getSample3).sum());

                listVo.setVisit4(excelListVos.stream().filter(Po -> Po.getVisit4() != null).mapToInt(ExcelListVo::getVisit4).sum());
                listVo.setCustom4(excelListVos.stream().filter(Po -> Po.getCustom4() != null).mapToInt(ExcelListVo::getCustom4).sum());
                listVo.setSample4(excelListVos.stream().filter(Po -> Po.getSample4() != null).mapToInt(ExcelListVo::getSample4).sum());

                listVo.setVisit5(excelListVos.stream().filter(Po -> Po.getVisit5() != null).mapToInt(ExcelListVo::getVisit5).sum());
                listVo.setCustom5(excelListVos.stream().filter(Po -> Po.getCustom5() != null).mapToInt(ExcelListVo::getCustom5).sum());
                listVo.setSample5(excelListVos.stream().filter(Po -> Po.getSample5() != null).mapToInt(ExcelListVo::getSample5).sum());

                listVo.setVisit6(excelListVos.stream().filter(Po -> Po.getVisit6() != null).mapToInt(ExcelListVo::getVisit6).sum());
                listVo.setCustom6(excelListVos.stream().filter(Po -> Po.getCustom6() != null).mapToInt(ExcelListVo::getCustom6).sum());
                listVo.setSample6(excelListVos.stream().filter(Po -> Po.getSample6() != null).mapToInt(ExcelListVo::getSample6).sum());

                listVo.setVisit7(excelListVos.stream().filter(Po -> Po.getVisit7() != null).mapToInt(ExcelListVo::getVisit7).sum());
                listVo.setCustom7(excelListVos.stream().filter(Po -> Po.getCustom7() != null).mapToInt(ExcelListVo::getCustom7).sum());
                listVo.setSample7(excelListVos.stream().filter(Po -> Po.getSample7() != null).mapToInt(ExcelListVo::getSample7).sum());

                listVo.setVisit8(excelListVos.stream().filter(Po -> Po.getVisit8() != null).mapToInt(ExcelListVo::getVisit8).sum());
                listVo.setCustom8(excelListVos.stream().filter(Po -> Po.getCustom8() != null).mapToInt(ExcelListVo::getCustom8).sum());
                listVo.setSample8(excelListVos.stream().filter(Po -> Po.getSample8() != null).mapToInt(ExcelListVo::getSample8).sum());

                listVo.setVisit9(excelListVos.stream().filter(Po -> Po.getVisit9() != null).mapToInt(ExcelListVo::getVisit9).sum());
                listVo.setCustom9(excelListVos.stream().filter(Po -> Po.getCustom9() != null).mapToInt(ExcelListVo::getCustom9).sum());
                listVo.setSample9(excelListVos.stream().filter(Po -> Po.getSample9() != null).mapToInt(ExcelListVo::getSample9).sum());

                listVo.setVisit10(excelListVos.stream().filter(Po -> Po.getVisit10() != null).mapToInt(ExcelListVo::getVisit10).sum());
                listVo.setCustom10(excelListVos.stream().filter(Po -> Po.getCustom10() != null).mapToInt(ExcelListVo::getCustom10).sum());
                listVo.setSample10(excelListVos.stream().filter(Po -> Po.getSample10() != null).mapToInt(ExcelListVo::getSample10).sum());

                listVo.setVisit11(excelListVos.stream().filter(Po -> Po.getVisit11() != null).mapToInt(ExcelListVo::getVisit11).sum());
                listVo.setCustom11(excelListVos.stream().filter(Po -> Po.getCustom11() != null).mapToInt(ExcelListVo::getCustom11).sum());
                listVo.setSample11(excelListVos.stream().filter(Po -> Po.getSample11() != null).mapToInt(ExcelListVo::getSample11).sum());

                listVo.setVisit12(excelListVos.stream().filter(Po -> Po.getVisit12() != null).mapToInt(ExcelListVo::getVisit12).sum());
                listVo.setCustom12(excelListVos.stream().filter(Po -> Po.getCustom12() != null).mapToInt(ExcelListVo::getCustom12).sum());
                listVo.setSample12(excelListVos.stream().filter(Po -> Po.getSample12() != null).mapToInt(ExcelListVo::getSample12).sum());

                listVo.setVisit13(excelListVos.stream().filter(Po -> Po.getVisit13() != null).mapToInt(ExcelListVo::getVisit13).sum());
                listVo.setCustom13(excelListVos.stream().filter(Po -> Po.getCustom13() != null).mapToInt(ExcelListVo::getCustom13).sum());
                listVo.setSample13(excelListVos.stream().filter(Po -> Po.getSample13() != null).mapToInt(ExcelListVo::getSample13).sum());

                listVo.setVisit14(excelListVos.stream().filter(Po -> Po.getVisit14() != null).mapToInt(ExcelListVo::getVisit14).sum());
                listVo.setCustom14(excelListVos.stream().filter(Po -> Po.getCustom14() != null).mapToInt(ExcelListVo::getCustom14).sum());
                listVo.setSample14(excelListVos.stream().filter(Po -> Po.getSample14() != null).mapToInt(ExcelListVo::getSample14).sum());

                listVo.setVisit15(excelListVos.stream().filter(Po -> Po.getVisit15() != null).mapToInt(ExcelListVo::getVisit15).sum());
                listVo.setCustom15(excelListVos.stream().filter(Po -> Po.getCustom15() != null).mapToInt(ExcelListVo::getCustom15).sum());
                listVo.setSample15(excelListVos.stream().filter(Po -> Po.getSample15() != null).mapToInt(ExcelListVo::getSample15).sum());

                excelListVos.add(listVo);
                excelListVos1.addAll(excelListVos);

            }

        }

        excelListVos.clear();

        List<ExcelListVo> collect5 = excelListVos1.stream().distinct().collect(Collectors.toList());
        return collect5;
    }

    public Map<String, Object> getSalesList(String startTime, String id, Integer totalMoth, Integer totalWeek) {

        if (StringUtils.isEmpty(startTime)) {
            startTime = ((DateTime.now() + "").split(" ")[0].split("-")[0]) + ((DateTime.now() + "").split(" ")[0].split("-")[1]);
        }
//        Integer totalMoth = 800;
//        Integer totalWeek = 200;

        System.out.println("ididididid: " + id);

        List<Long> ids = Collections.singletonList(Long.parseLong(id));
        List<User> users = salesPlanMapper.findById(ids);
        Map<String, Object> salesmanRepu = getSalesmanRepu(startTime, users, totalMoth, totalWeek);
        Map<String, Object> salesmanMap = new HashMap<>();
        salesmanMap.put("saleData", salesmanRepu.get("saleData"));
        salesmanMap.put("monthTotal", salesmanRepu.get("monthTotal"));
        List<SalesmanList> collect1 = (List<SalesmanList>) salesmanRepu.get("salesmanList");
        List<Map<String, Object>> charts = (List<Map<String, Object>>) salesmanRepu.get("chartData");


        String name = collect1.get(0).getName();
        String avatar = collect1.get(0).getAvatar();
        int type = collect1.get(0).getType();

        //标准
        int sampleFinished = collect1.get(0).getSampleFinished();
        int sampleUnf = collect1.get(0).getSampleUnf();

        //定制
        int customFinished = collect1.get(0).getCustomFinished();
        int customUnf = collect1.get(0).getCustomUnf();

        //拜访
        int recordFinished = collect1.get(0).getRecordFinished();
        int recordUnf = collect1.get(0).getRecordUnf();

        SalesmanList salesmanList = new SalesmanList();
        salesmanList.setId(collect1.get(0).getId());
        salesmanList.setAvatar(avatar);
        salesmanList.setName(name);
        salesmanList.setType(type);
        salesmanList.setSampleUnf(sampleUnf);
        salesmanList.setSampleFinished(sampleFinished);
        salesmanList.setVisitFinished(recordFinished);
        salesmanList.setVisitUnf(recordUnf);
        salesmanList.setCustomFinished(customFinished);
        salesmanList.setCustomUnf(customUnf);
        salesmanMap.put("userDetail", salesmanList);


        List<Map<String, Object>> mapList = new ArrayList<>();
        for (int i = 0; i < charts.size(); i++) {

            Map<String, Object> userTotal = new HashMap<>();
            userTotal.put("visitTarget", totalWeek);
            userTotal.put("visitFinished", charts.get(i).get("data1"));
            userTotal.put("visitUnf", totalWeek - (Integer) charts.get(i).get("data1"));
            userTotal.put("customTarget", totalWeek);
            userTotal.put("customFinished", charts.get(i).get("data2"));
            userTotal.put("customUnf", totalWeek - (Integer) charts.get(i).get("data2"));
            userTotal.put("sampleTarget", totalWeek);
            userTotal.put("sampleFinished", charts.get(i).get("data3"));
            userTotal.put("sampleUnf", totalWeek - (Integer) charts.get(i).get("data3"));
            mapList.add(userTotal);

        }
        salesmanMap.put("userTotal", mapList);


        return salesmanMap;
    }
}
